#include <QtCore/QCoreApplication>
#include "logicmanager.h"
#include "networkmanager.h"

void setConnection(NetworkManager & network, LogicManager & logic);

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    NetworkManager *networkManager = new NetworkManager();
    LogicManager *logicManager = new LogicManager();
    // Setup Connection
    // TODO:
    setConnection(*networkManager, *logicManager);
    int result = app.exec();

    delete logicManager;
    delete networkManager;
    return result;
}

void setConnection(NetworkManager & network, LogicManager & logic)
{
    QObject::connect(&network, SIGNAL(recieveData(QString, QByteArray)),
                     &logic, SLOT(onReceivedData(const QString &, const QByteArray &)));
    QObject::connect(&network, SIGNAL(notify(QString ,int)),
                     &logic, SLOT(onNotify(const QString &, int)));

    QObject::connect(&logic, SIGNAL(sendData(const QString &, const QByteArray &)),
                     &network, SLOT(onSendData(QString, QByteArray)));
    QObject::connect(&logic, SIGNAL(sendLogout(const QString &)),
                     &network, SLOT(onCloseConnection(QString)));
}
